package com.golxen.framework.common;



import com.golxen.framework.common.server.eServerType;
import com.golxen.utils.LogUtil;
import com.golxen.utils.YmlUtil;

import java.util.HashSet;
import java.util.Set;

public class BuiltinPlugin {

    int serverId = -1;
    int crossServerId = -1;
//    int cross2ServerId = -1;
//    int activityTestServerId = -1;
    int channelId;
//    boolean userCenter;
//    boolean inner;
    boolean isGameServer;
    boolean isCrossServer;
//    boolean isCross2Server;
    boolean isAuditServer;
    Set<eServerType> serverType = new HashSet<>();


    static BuiltinPlugin instance = null;

    public static void start() throws Throwable {
        if (instance != null) {
            return;
        }

        instance = new BuiltinPlugin();

        instance.isGameServer = "1".equals(YmlUtil.getString("isGameServer"));
        instance.isCrossServer = "1".equals(YmlUtil.getString("isCrossServer"));
//        instance.isCross2Server = "1".equals(YmlUtils.getString("isCross2Server"));
//        instance.userCenter = "1".equals(YmlUtils.getString("isUserCenter"));
//        instance.inner = "1".equals(YmlUtils.getString("isInner"));
        instance.channelId = Integer.parseInt(YmlUtil.getString("channelId"));
        instance.serverId = Integer.parseInt(YmlUtil.getString("serverId"));
//        setActivityTestServerId(instance.serverId);
        instance.crossServerId = Integer.parseInt(YmlUtil.getString("crossServerId"));
//        instance.cross2ServerId = Integer.parseInt(YmlUtils.getString("cross2ServerId"));
    }

    public static void print() {
//        LogUtils.CONSOLE.info("[config] isInner={}", instance.inner);
//        LogUtils.CONSOLE.info("[config] userCenter={}", instance.userCenter);
        LogUtil.CONSOLE.info("[config] isGameServer={}", instance.isGameServer);
        LogUtil.CONSOLE.info("[config] isCrossServer={}", instance.isCrossServer);
//        LogUtils.CONSOLE.info("[config] isCross2Server={}", instance.isCross2Server);
        LogUtil.CONSOLE.info("[config] serverId={}", instance.serverId);
        LogUtil.CONSOLE.info("[config] crossServerId={}", instance.crossServerId);
//        LogUtils.CONSOLE.info("[config] cross2ServerId={}", instance.cross2ServerId);
        LogUtil.CONSOLE.info("[config] channelId={}", instance.channelId);
    }

    public static boolean active() {
        return instance != null;
    }

    public static int getServerId() {
        return instance.serverId;
    }

    public static int getCrossServerId() {
        return instance.crossServerId;
    }

//    public static int getCross2ServerId() {
//        return instance.cross2ServerId;
//    }

//    public static int getActivityTestServerId() {
//        return instance.activityTestServerId;
//    }

//    public static void setActivityTestServerId(int activityTestServerId) {
//        instance.activityTestServerId = activityTestServerId;
//    }

    public static int getChannelId() {
        return instance.channelId;
    }

//    public static boolean isUserCenter() {
//        return instance.userCenter;
//    }

//    public static boolean isInner() {
//        return instance.inner;
//    }

    public static boolean isGameServer() {
        return instance.isGameServer;
    }

    public static boolean isCrossServer() {
        return instance.isCrossServer;
    }

//    public static boolean isCross2Server() {
//        return instance.isCross2Server;
//    }

    public static boolean isAuditServer() {
        return instance.isAuditServer;
    }

    public static Set<eServerType> getServerType() {
        return instance.serverType;
    }

    public static boolean is(eServerType serverType) {
        return instance.serverType.contains(serverType);
    }





}
